package com.witsight.cassandra.bean;

import javax.xml.bind.annotation.XmlAttribute;
import javax.xml.bind.annotation.XmlValue;
import javax.xml.bind.annotation.adapters.CollapsedStringAdapter;
import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter;

import org.apache.commons.lang3.builder.HashCodeBuilder;

import com.witsight.platform.adapter.ClassStringAdapter;
import com.witsight.platform.model.IBaseObject;
import com.witsight.platform.util.io.XMLUtil;

/**   
 * 说明：配置的sql的内容，直接映射每一个XML
 * @Title: QueryInfo.java 
 * @Package com.witsight.cassandra.bean 
 * @See: {@link IBaseObject}
 * 		 {@link XMLUtil}
 * Copyright: Copyright (c) 2017
 * @author: penght  
 * @date: 2017年9月20日 下午3:34:43 
 * @version: V1.0
 *
 */
public class NameQuery implements IBaseObject {
	private static final long serialVersionUID = -530172991819591714L;
	// 名称
	private String name;	
	
    private String query;
	// 返回的结果类
	private Class<?> result;
	
	@XmlValue
	@XmlJavaTypeAdapter(CollapsedStringAdapter.class)
	public String getQuery() {
		return query;
	}
	public void setQuery(String query) {
		this.query = query;
	}
	@XmlAttribute(name = "name", required = true)
	public String getName() {
		return name;
	}
	public void setName(String name) {
		this.name = name;
	}
	
	@XmlAttribute(name = "result")
	@XmlJavaTypeAdapter(ClassStringAdapter.class)
	public Class<?> getResult() {
		return result;
	}
	public void setResult(Class<?> result) {
		this.result = result;
	}
	
	@Override
	public boolean equals(Object o) {
		if (this == o) {
			return true;
		}
		if (!(o instanceof NameQuery)) {
			return false;
		}

		final NameQuery nameQuery = (NameQuery) o;
		return !(this.getName() != null ? !this.getName().equals(nameQuery.getName()) : nameQuery.getName() != null);
	}
	
	@Override
	public int hashCode() {
		return new HashCodeBuilder().append(getName()).toHashCode();
	}
}
